package de.szut.sudoku.gui.sudokufield;

import java.awt.event.KeyEvent;

import javax.swing.JLabel;

import de.szut.sudoku.gui.MainFrame;

/**
 * Note key listener
 * 
 * @author Marc Huisinga
 * 
 */
public class SudokuNoteKeyListener extends SudokuKeyListener {

	/**
	 * Key pressed event
	 */
	public void keyPressed(KeyEvent keyEvent) {
		// resets the number or inputs a number
		setKeyEvent(keyEvent);
		JLabel source = (JLabel) getKeyEvent().getSource();
		if (isReset()) {
			source.setText(null);
		} else if (isNumber()) {
			source.setText(Character.toString(keyEvent.getKeyChar()));
		}

		MainFrame.getInstance().revalidate();
		MainFrame.getInstance().repaint();
	}
}
